/**
 * 六面体实体类demo案例
 */

import * as Cesium from "cesium";
import * as EasyCesium from "@xhymf1992/easy-cesium";

export async function drawHexahedron() {

    let postionsCarto = [
        [121.30237954163225, 24.98229159573676, 215.0],
        [121.30237954163225, 24.98231723652743, 215.0],
        [121.30233892405339, 24.98231723652743, 215.0],
        [121.30233892405339, 24.98229159573676, 215.0],
        [121.30237954163225, 24.98229159573676, 185.0],
        [121.30237954163225, 24.98231723652743, 185.0],
        [121.30233892405339, 24.98231723652743, 185.0],
        [121.30233892405339, 24.98229159573676, 185.0]
    ];

    
    let positionsCar3 = [];
    for(let position of postionsCarto) {
        // @ts-ignore
        positionsCar3.push(Cesium.Cartesian3.fromDegrees(...position));
    }


    console.log(positionsCar3);
        
    let options = {
        id: "hexahedron", // id，具有唯一性，必填
        name: "hexahedron", // 名称，可选，默认为空
        show: true, // 是否显示，可选，默认显示
        /**
        * 六面体坐标集，必填，排列顺序如下
        *   v1-----v2
        *  /      /
        * v0-----v3
        * 
        *   v5-----v6
        *  /      /
        * v4-----v7
        */
        positions: positionsCar3,
        color: "rgba(0,255,0,1)", // 六面体颜色，可选，默认为rgba(255, 255, 255, 1)
        viewer: window.viewer // cesium视图对象，必填
    };

    // @ts-ignore
    window.hexahedron = new EasyCesium.Hexahedron(options);
    // @ts-ignore
    window.hexahedron.init();
    // @ts-ignore
    window.hexahedron.flyTo();

    // // 切换显隐
    // window.hexahedron.show = false;
    // window.hexahedron.show = true;

    // // 修改颜色
    // window.hexahedron.color = "rgba(255,255,0,1)";
    
    // // 销毁
    // window.hexahedron.destroy();

}